﻿using System;
using System.Collections.Generic;
using Nop.Core.Domain.Shipping;

namespace Nop.Core.Domain.Logistics
{
    public class LogisticsPackage : BaseEntity
    {
        private ICollection<PackageNote> _packageNotes;

        #region Ctor

        public LogisticsPackage()
        {
            //We can always change the structure of package note/event history, but should increase the version here
            //So the struct can be decided later in service.
            PackageNoteVersion = 1;
        }

        #endregion

        #region Properties

        public int ShipmentId { get; set; }

        public int? WarehouseId { get; set; }

        public int? ToWarehouseId { get; set; }

        public int PickUpLocationId { get; set; }

        public int DeliveryLocationId { get; set; }

        public int? ApplicatorId { get; set; }

        //public virtual int BranchId { get; set; }

        public int PackageNoteVersion { get; set; }

        public DateTime CreatedOnUtc { get; set; }

        public DateTime? UpdatedOnUtc { get; set; }

        public DateTime? ReadyOnUtc { get; set; }
        public DateTime? PickupEndOnUtc { get; set; }

        public ShippingStatus Status { get; set; }

        public int? DeliveryAttemptCount { get; set; }

        public int DeliveryRescheduleCount { get; set; }

        public int DeliveryAddressChangeCount { get; set; }

        public int OrderKindId { get; set; }

        #endregion

        #region Navigation properties

        public virtual Shipment Shipment { get; set; }

        //public virtual Branch Branch { get; set; }

        public virtual LogisticsWarehouse Warehouse { get; set; }

        public virtual LogisticsWarehouse ToWarehouse { get; set; }

        public virtual LogisticsLocation PickUpLocation { get; set; }

        public virtual LogisticsLocation DeliveryLocation { get; set; }

        public virtual ICollection<PackageNote> PackageNotes
        {
            get { return _packageNotes ?? (_packageNotes = new List<PackageNote>()); }
            protected set { _packageNotes = value; }
        }

        #endregion
    }
}
